<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title>.::แก้ไขข้อมูลข้อมูล::.</title>
</head>
<body>
    <br>
    <table width="150" border="0" align="center" cellspacing="0">
   
  <?  
             	  		        $timestamp = time();
					$H= date("H",$timestamp);
					$min= date("i",$timestamp);
					$sec= date("s",$timestamp);
					$H_del=$H-1;
					$Ctime="$H_del:$min:$sec"; 
                                        $today= date("Y-m-d H:i:s");
//                                        $today= date("Y-m-d");
  
$objConnect = mysql_connect("localhost","root","password") or die("Error Connect to Database");
$objDB = mysql_select_db("regisonline");

 
 $regisid = $_POST['regisid'];
 $studyid = $_POST['studyid'];
 $eduid   = $_POST['eduid'];
 $addressid = $_POST['addressid'];
 $parentid = $_POST['parentid'];
 $hostid = $_POST['hostid'];

if ($_POST['firstname'] != ""){
                     $countdata=count($_POST['lastname']);
                     for ($i=0;$i<$countdata;$i++) {
                         
$countdata=count($_POST['lastname']);
$firstname=$_POST["firstname"][$i];
$lastname=$_POST["lastname"][$i];
$citizenid=$_POST["citizenid"][$i];
$birthday=$_POST["birthday"][$i];
$nation=$_POST["nation"][$i];
$race=$_POST["race"][$i];
$religion=$_POST["religion"][$i];
$email=$_POST["email"][$i];                         
                         
                         
                  
$study_str = array('studyid','firstname','lastname','citizenid','birthday','nation','race','religion','email');
$study_val = array($studyid,$firstname,$lastname,$citizenid,$birthday,$nation,$race,$religion,$email);

$strSQL = "UPDATE study "; 
$strSQL .=" SET $study_str[1]='$study_val[1]' ,$study_str[2]='$study_val[2]',$study_str[3]='$study_val[3]',$study_str[4]='$study_val[4]',$study_str[5]='$study_val[5]',$study_str[6]='$study_val[6]',$study_str[7]='$study_val[7]',$study_str[8]='$study_val[8]' ";
$strSQL .=" WHERE $study_str[0]='$study_val[0]' ";

/*$strSQL .="('$id','".$_POST["firstname"]."','".$_POST["lastname"]."','".$_POST["citizenid"]."' ";
$strSQL .=",'".$_POST["nation"]."','".$_POST["race"]."','".$_POST["religion"]."','".$_POST["email"]."') ";*/
$objQuery = mysql_query($strSQL);
        }
   }


if ($_POST['addresstype'] != ""){
                     $countdata=count($_POST['address']);
                     for ($i=0;$i<$countdata;$i++) {
                         
$countdata=count($_POST['address']);
$addresstype=$_POST["addresstype"][$i];
$address=$_POST["address"][$i];
$moo=$_POST["moo"][$i];
$village=$_POST["village"][$i];
$lane=$_POST["lane"][$i];
$road=$_POST["road"][$i];
$province=$_POST["province"][$i];
$district=$_POST["district"][$i];
$subdistrict=$_POST["subdistrict"][$i];
$postcode=$_POST["postcode"][$i];
$phone=$_POST["phone"][$i];
$mobile=$_POST["mobile"][$i];

$add_str = array('addressid','addresstype','address','moo','village','lane','road','province','district','subdistrict','postcode','phone','mobile','updatedate');
$add_val = array($addressid,$addresstype,$address,$moo,$village,$lane,$road,$province,$district,$subdistrict,$postcode,$phone,$mobile,$today);

$strSQL = "UPDATE address ";
$strSQL .=" SET $add_str[1]='$add_val[1]' ,$add_str[2]='$add_val[2]',$add_str[3]='$add_val[3]',$add_str[4]='$add_val[4]',$add_str[5]='$add_val[5]',$add_str[6]='$add_val[6]',$add_str[7]='$add_val[7]',$add_str[8]='$add_val[8]',$add_str[9]='$add_val[9]' ,$add_str[10]='$add_val[10]' ,$add_str[11]='$add_val[11]' ,$add_str[12]='$add_val[12]' ,$add_str[13]='$add_val[13]' ";
$strSQL .=" WHERE $add_str[0]='$add_val[0]' ";

/*$strSQL .="('$id1','".$_POST["addresstype"]."','".$_POST["address"]."','".$_POST["moo"]."' ";
$strSQL .=",'".$_POST["village"]."','".$_POST["lane"]."','".$_POST["road"]."','".$_POST["province"]."' ";
$strSQL .=",'".$_POST["district"]."','".$_POST["subdistrict"]."','".$_POST["postcode"]."','".$_POST["phone"]."','".$_POST["mobile"]."',NOW(),NOW()) ";*/
//echo "<BR>".$strSQL."<BR>";
$objQuery = mysql_query($strSQL);
           }
        }
        
if ($_POST['firstname'] != ""){
                     $countdata=count($_POST['lastname']);
                     for ($i=0;$i<$countdata;$i++) {
                         
$countdata=count($_POST['lastname']);
//$firstname=$_POST["firstname"][$i];
$fromschool=$_POST["fromschool"][$i];
$province1=$_POST["province1"][$i];
$subdistrict1=$_POST["subdistrict1"][$i];
$district1=$_POST["district1"][$i];

$edu_str = array('eduid','fromschool','province','subdistrict','district','updatedate');
$edu_val = array($eduid,$fromschool,$province1,$subdistrict1,$district1,$today);

$strSQL = "UPDATE education ";
$strSQL .=" SET $edu_str[1]='$edu_val[1]' ,$edu_str[2]='$edu_val[2]',$edu_str[3]='$edu_val[3]',$edu_str[4]='$edu_val[4]',$edu_str[5]='$edu_val[5]' ";
$strSQL .=" WHERE $edu_str[0]='$edu_val[0]' ";

/*$strSQL .="('$id','".$_POST["firstname"]."','".$_POST["lastname"]."','".$_POST["citizenid"]."' ";
$strSQL .=",'".$_POST["nation"]."','".$_POST["race"]."','".$_POST["religion"]."','".$_POST["email"]."') ";*/
$objQuery = mysql_query($strSQL);
        }
   }

   
if ($_POST['firstname'] != ""){
                     $countdata=count($_POST['lastname']);
                     for ($i=0;$i<$countdata;$i++) {
                         
$countdata=count($_POST['lastname']);
$firstname1=$_POST["firstname1"][$i];
$lastname1=$_POST["lastname1"][$i];
$occupation=$_POST["occupation"][$i];
$citizenid1=$_POST["citizenid1"][$i];
$phone1=$_POST["phone1"][$i];
$mobile1=$_POST["mobile1"][$i];
$relation=$_POST["relation"][$i];

$part_str = array('parentid','relation','firstname','lastname','occupation','citizenid','phone','mobile','updatedate');
$part_val = array($parentid,$relation,$firstname1,$lastname1,$occupation,$citizenid1,$phone1,$mobile1,$today);

$strSQL = "UPDATE parent ";
$strSQL .=" SET $part_str[1]='$part_val[1]' ,$part_str[2]='$part_val[2]',$part_str[3]='$part_val[3]',$part_str[4]='$part_val[4]',$part_str[5]='$part_val[5]',$part_str[6]='$part_val[6]',$part_str[7]='$part_val[7]',$part_str[8]='$part_val[8]' ";
$strSQL .=" WHERE $part_str[0]='$part_val[0]' ";

/*$strSQL .="('$id1','".$_POST["addresstype"]."','".$_POST["address"]."','".$_POST["moo"]."' ";
$strSQL .=",'".$_POST["village"]."','".$_POST["lane"]."','".$_POST["road"]."','".$_POST["province"]."' ";
$strSQL .=",'".$_POST["district"]."','".$_POST["subdistrict"]."','".$_POST["postcode"]."','".$_POST["phone"]."','".$_POST["mobile"]."',NOW(),NOW()) ";*/
$objQuery = mysql_query($strSQL);
           }
        }
        
if ($_POST['firstname'] != ""){
                     $countdata=count($_POST['lastname']);
                     for ($i=0;$i<$countdata;$i++) {
                         
$countdata=count($_POST['lastname']);
$firstname2=$_POST["firstname2"][$i];
$lastname2=$_POST["lastname2"][$i];
$occupation1=$_POST["occupation1"][$i];
$citizenid2=$_POST["citizenid2"][$i];
$phone2=$_POST["phone2"][$i];
$mobile2=$_POST["mobile2"][$i];

$part_str = array('hostid','firstname','lastname','occupation','citizenid','phone','mobile','createdate','updatedate');
$part_val = array($hostid,$firstname2,$lastname2,$occupation1,$citizenid2,$phone2,$mobile2,$today);

$strSQL = "UPDATE host ";
$strSQL .=" SET $part_str[1]='$part_val[1]' ,$part_str[2]='$part_val[2]',$part_str[3]='$part_val[3]',$part_str[4]='$part_val[4]',$part_str[5]='$part_val[5]',$part_str[6]='$part_val[6]',$part_str[7]='$part_val[7]',$part_str[8]='$part_val[8]' ";
$strSQL .=" WHERE $part_str[0]='$part_val[0]' ";

/*$strSQL .="('$id1','".$_POST["addresstype"]."','".$_POST["address"]."','".$_POST["moo"]."' ";
$strSQL .=",'".$_POST["village"]."','".$_POST["lane"]."','".$_POST["road"]."','".$_POST["province"]."' ";
$strSQL .=",'".$_POST["district"]."','".$_POST["subdistrict"]."','".$_POST["postcode"]."','".$_POST["phone"]."','".$_POST["mobile"]."',NOW(),NOW()) ";*/
$objQuery = mysql_query($strSQL);
           }
        }
        
if($objQuery)
{
    
	echo "<div align='center'><font color='#ff0000'><b>บันทึกข้อมูลเรียบร้อย<b></font></div>";
?>
        <script>
            alert("บันทึกข้อมูลเรียบร้อยแล้ว >>");
            window.location="/regisonline/template?phppage=adminedit.php";
        </script>
<?        
}
else
{
	echo "Error Save [".$strSQL."]";
        ?>
        <script>
            alert("!เกิดข้อผิดพลาด กรุณาเข้าเมนูใหม่ >>");
            window.location="/regisonline/template?phppage=adminedit.php";
        </script>
<?   
}
mysql_close($objConnect);
            

?>
        
    <tr><td colspan="2">
      <div align="center"><a href="/regisonline/template?phppage=adminedit.php&editPrt"> <img src="/regisonline/resources/images/gif/gif1.bmp" width="400" height="40"  ></a></div></td></tr>
    <br><br><tr><td><br></td></tr>
    <tr><td colspan="2">
      <div align="center"><a href="/regisonline/template?phppage=adminedit.php&searchPrt"> <img src="/regisonline/resources/images/gif/gif6.bmp" width="200" height="40"  ></a></div></td></tr>       
        
 </table>
</body>
</html>